package com.cms.action;

import java.util.List;

import com.cms.entity.Topic;
import com.cms.service.TopicService;
import com.opensymphony.xwork2.ActionSupport;

public class TopicAction extends ActionSupport {
	
	private int id;

	private TopicService topicService;
	
	private Topic topic;
	
	List<Topic> topicList;

	
	@Override
	public String execute(){
		topicList = topicService.queryTopics(topic);
		return SUCCESS;
	}
	
	public String toSave(){
		return "toSave";
	}
	
	public String save(){
		topicService.save(topic);
		return "save";
	}

	public String toUpdate(){
		topic = topicService.get(id);
		return "toUpdate";
	}
	
	public String update(){
		topicService.update(topic);
		return "update";
	}
	
	public String delete(){
		topicService.delete(id);
		return "delete";
	}
	
	public String get(){
		topic = topicService.get(id);
		return "get";
	}

	
	
	
	
	public TopicService getTopicService() {
		return topicService;
	}
	public void setTopicService(TopicService topicService) {
		this.topicService = topicService;
	}

	public Topic getTopic() {
		return topic;
	}
	public void setTopic(Topic topic) {
		this.topic = topic;
	}

	public List<Topic> getTopicList() {
		return topicList;
	}
	public void setTopicList(List<Topic> topicList) {
		this.topicList = topicList;
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}


}
